﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NOAH.CMS.Repository;

namespace NOAH.CMS.Cache
{
    public class ConfigCacheLayer : BaseCacheLayer
    {
        private ConfigRepository _repositoryAPI = null;

        public List<Config> GetAll()
        {
            List<Config> cates = this.GetCacheItem("AllConfig") as List<Config>;
            if (cates == null)
            {
                cates = (from p in this.API.GetAll()
                         orderby p.ID
                         select p).ToList<Config>();
                this.AddCacheItem("AllConfig", cates);
            }
            return cates;
        }

        protected override string[] MasterCacheKeyArray()
        {
            return new string[] { "ConfigCache" };
        }

        protected ConfigRepository API
        {
            get
            {
                if (this._repositoryAPI == null)
                {
                    this._repositoryAPI = new ConfigRepository();
                }
                return this._repositoryAPI;
            }
        }
    }
}
